var events= require("events");
var Emitter=events.EventEmitter;
function Dog(name,energy){
    Emitter.call(this);
    this.name=name;
    this.energy=energy;
}

Dog.prototype=Emitter.prototype;
Dog.prototype.bark=function(){
    setInterval(() => {
        if(this.energy>=0){
            console.log(this.name+"bark!!"+"energy:"+this.energy--);
        }else{
            
        }           
    }, 1000);
}

module.exports=Dog;